package system

import (
	"io/ioutil"
	"log"
	"gopkg.in/yaml.v2"
)

type DBConf struct {
	Host string `yaml:"host"`
	Port int `yaml:"port"`
	User string `yaml:"user"`
	Password string `yaml:"password"`
	DbName string `yaml:"dbName"`
}

//path, _ := os.Getwd()
//path + "/conf/db.yml"
func (dbConf *DBConf) GetDBConf(path string) *DBConf {

	f, err := ioutil.ReadFile(path)
	if err != nil {
		log.Printf("f.Get err   #%v ", err)
	}
	err = yaml.Unmarshal(f, dbConf)
	if err != nil {
		log.Fatalf("Unmarshal: %v", err)
	}

	return dbConf
}